//分页
function pageBox(pageInfo){
	var $pageBox = $(".pageBox");
	var $pageNumBox = $(".pageBox p");
	var $navigatepageNums = pageInfo.navigatepageNums;
	$pageBox.find("a").remove();
	$pageBox.find("span").remove();
	var $firstPage = $("<a href='#' data-page='1'>首页</a>");
	var $prePage = $("<a href='#' data-page='" + pageInfo.prePage + "'>上一页</a>");
	var $nextPage = $("<a href='#' data-page='" + pageInfo.nextPage + "'>下一页</a>");
	var $lastPage = $("<a href='#' data-page='" + pageInfo.pages + "'>尾页</a>");
	var $pageInfo = $("<span>" + pageInfo.pageNum + "/" + pageInfo.pages + "</span>");
	if(pageInfo.pages<=5){
		for(var i=1;i<=$navigatepageNums.length;i++){
			if(i == pageInfo.pageNum){
				var $a = $("<a href='#' class='active' data-page='" + i + "'>" + i + "</a>");
			}else{
				var $a = $("<a href='#' data-page='" + i + "'>" + i + "</a>");
			}
			$pageNumBox.append($a);
		}
	}
	else{
		if(pageInfo.pageNum<4){
			for(var i=1;i<=5;i++){
				if(i == pageInfo.pageNum){
					var $a = $("<a href='#' class='active' data-page='" + i + "'>" + i + "</a>");
				}else{
					var $a = $("<a href='#' data-page='" + i + "'>" + i + "</a>");
				}
				$pageNumBox.append($a);
			}
		}
		else if(pageInfo.pageNum>=4 && pageInfo.pageNum<=(pageInfo.pages-2)){
			var $a = $("<a href='#' data-page='" + (pageInfo.pageNum-2) + "'>" + (pageInfo.pageNum-2) + "</a>"
					+ "<a href='#' data-page='" + (pageInfo.pageNum-1) + "'>" + (pageInfo.pageNum-1) + "</a>"
					+ "<a href='#' class='active' data-page='" + pageInfo.pageNum + "'>" + pageInfo.pageNum + "</a>"
					+ "<a href='#' data-page='" + (pageInfo.pageNum+1) + "'>" + (pageInfo.pageNum+1) + "</a>"
					+ "<a href='#' data-page='" + (pageInfo.pageNum+2) + "'>" + (pageInfo.pageNum+2) + "</a>"
			);
			$pageNumBox.append($a);
		}
		else{
			for(var i=(pageInfo.pages-4);i<=pageInfo.pages;i++){
				if(i == pageInfo.pageNum){
					var $a = $("<a href='#' class='active' data-page='" + i + "'>" + i + "</a>");
				}else{
					var $a = $("<a href='#' data-page='" + i + "'>" + i + "</a>");
				}
				$pageNumBox.append($a);
			}
		}
	}
	$pageBox .append($firstPage);
	$pageBox .append($prePage);
	$pageBox .append($pageNumBox);
	$pageBox .append($nextPage);
	$pageBox .append($lastPage);
	$pageBox .append($pageInfo);
}
